using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CandleController : MonoBehaviour
{
    private GameObject prefabEffect;

    void Awake()
    {
        prefabEffect = Resources.Load<GameObject>("Prefabs/Effects/Stars");
    }

    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.name == Defines.MainCharacterName)
        {
            var currentQuest = QuestSystem.Instance.CurrentQuest;
            if(currentQuest is CollectCandles && currentQuest.Status == QuestStatus.InProgress)
            {
                Instantiate(prefabEffect, gameObject.transform);
                Destroy(gameObject);
                var collectCandleQuest = currentQuest as CollectCandles;
                collectCandleQuest.Count++;
                if (collectCandleQuest.Count >= 5)
                {
                    // 蜡烛收集完成
                    currentQuest.Status = QuestStatus.Completed;
                    GameManager.Instance.PlaySoundCompleteQuest();
                }
            }
        }
    }
}
